package vmcs.store;

import vmcs.common.VMCSException;

public class DrinkData extends Data {
	public DrinkData() throws VMCSException
	{
		super();
		dataImpl=implFactory.getDrinkImplementation();
		dataImpl.initialize();
	}
	@Override
	public StoreItem getItem(int id) {
		DrinksStoreItem cit;

		DrinksBrand db = new DrinksBrand();
		String item, itemv;

		item = new String("Name" + id);
		itemv = dataImpl.getValue(item);

		db.setName(itemv);

		item = new String("Price" + id);
		itemv = dataImpl.getValue(item);
		db.setPrice(Integer.parseInt(itemv));

		item = new String("Quantity" + id);
		itemv = dataImpl.getValue(item);

		cit = new DrinksStoreItem(db, Integer.parseInt(itemv));

		return cit;
	}
	
	@Override
	public void setItem(int it, StoreItem item) {
		// TODO Auto-generated method stub
		String  itn;
	    int  itemv;
	    String  its;
	    DrinksBrand  cn;
	    int idx = it + 1;

	    cn = (DrinksBrand) item.getContent();
	    itn = new String("Name" + idx);

	    dataImpl.setValue(itn, cn.getName());

	    itn = new String("Price" + idx);
	    dataImpl.setValue(itn, String.valueOf(cn.getPrice()));

	    itn = new String("Quantity" + idx);
	    dataImpl.setValue(itn, String.valueOf(item.getQuantity()));
	  }

}
